<template>
    <view class="content">
        <text class="company">{{data.name}}</text>
        <view class="time-msg">
            诚e金缴纳<br/>
            起始时间:{{data.sincerStartTime}}<br/>
            截止时间:{{data.sincerEndTime}}<br/>
            解冻时间:{{data.sincerThawTime||'待定'}}<br/>
        </view>
        <view class="user-msg">
            <text style="color: rgba(1,1,1,0.5)">您的诚e金账户</text>
            <text  style="color: #479EEE">账户可用余额(元)</text>
            <view style="width: 100%"/>
            <text  style="color: rgba(1,1,1,0.5)">{{userData.card2}}</text>
            <text  style="color: #479EEE">{{balance.data.accountBalance}}</text>
        </view>
        <view class="user-msg">
            <text>姓名</text>
            <text>{{userData.trueName}}</text>
            <view style="width: 100%"/>
            <text>身份证号码</text>
            <text>{{userData.idCard}}</text>
            <view style="width: 100%"/>
            <text>手机号</text>
            <text>{{userData.user.mobile}}</text>
            <view style="width: 100%"/>
            <text>本楼盘诚e金缴存金额</text>
            <text>{{balance.buildingHoldBalance||'未缴存'}}</text>
        </view>
        <view style="background: white;border-top:1px solid #E8E8E8;">
<!--            <view class="plase-select">请选择工行账户类型</view>-->
<!--            <view class="select-item">-->
<!--                <radio-group @change="radioChange">-->
<!--                    <radio color="#D14F43"  value="1" />借记卡-->
<!--                    <radio style="margin-left: 30%" color="#D14F43"  value="2" />II类账户-->
<!--                </radio-group>-->
<!--            </view>-->
<!--            <view class="input-wrap" style="border-top:1px solid #E8E8E8;">-->
<!--                <text class="input-key">借记卡号</text>-->
<!--                <input v-model="phone" type="number" maxlength="18" placeholder="请输入卡号"/>-->
<!--            </view>-->
            <view class="input-wrap">
                <text class="input-key">诚e金金额(元)</text>
                <input v-model="num" type="number" maxlength="18" placeholder="请输入金额"/>
            </view>
        </view>
        <view class="but-wrap">
            <button type="warn"  class="sub-button" @click="save">
                立即缴存
            </button>
            <button type="warn"  class="sub-button" @click="goUrl('receive?type=1')">
                资金转入
            </button>
        </view>
		<view class="bottom-msg">
			<radio-group style="display: inline-block" @click.stop="agreeChange">
				<radio color="#D14F43"  :checked="agree" >我已阅读并同意</radio>
			</radio-group>
			<text style="color:#DC5C4B" @click="showPopup(1)">《中国工商银行线上“诚e金”业务协议书》</text>和
			<text style="color:#DC5C4B" @click="showPopup(2)">《个人银行电子账户服务协议》</text>
		</view>
        <view class="msg">
            温馨提示:
            1.在本楼盘诚e金缴存截止日前，您可进行资金缴存<br/>
            2.您可查询在我行缴存的诚e金明细
        </view>
    </view>
</template>

<script>
    import uniPopup from "@/components/uni-popup/uni-popup.vue"
    import util from "@/common/util.js"
    import API from '../../common/api.js';
    export default {
        components: {uniPopup},
        data() {
            return {
				popshow_0:false,
				agree:false,
                data:{},
                userData:JSON.parse(uni.getStorageSync('data')),
                balance:{},
                height: uni.getSystemInfoSync().windowHeight,
                num:0,
				popup:0,
            }
        },
        onLoad(option) {
            this.data=option
            this.data.sincerStartTime=new Date(this.data.sincerStartTime * 1000).format('yyyy-MM-dd')
            this.data.sincerEndTime=new Date(this.data.sincerEndTime * 1000).format('yyyy-MM-dd')
            this.data.sincerThawTime=new Date(this.data.sincerThawTime * 1000).format('yyyy-MM-dd')
        },
        onShow(){
            this.getData();
        },
        methods: {
			agreeChange(){
				this.agree=!this.agree;
				this.$forceUpdate();
				console.log(this.agree,'age')
			},
			showPopup(num){
			    // this.popup=num
				if(num===1){
					uni.navigateTo({
					    url: './agreement_0'
					});
				}else if(num===2){
					uni.navigateTo({
					    url: './agreement_1'
					});
				}
			},
            getData(){
                API.bankSincer({"buildingId": this.data.id,
                    "token": uni.getStorageSync('token')}).then(res=>{
                    this.balance=res
                })
            },
            goUrl(url){
                uni.navigateTo({
                    url: '../account/'+url
                });
            },
            save(){
                if(this.num<=0){
                    uni.showModal({
                        title: '提示',
                        content: '请输入大于0的金额',
                        showCancel: false,
                    });
                    return
                }
                uni.showModal({
                    title: '提示',
                    content: `确认缴存？`,
                    success: (res)=> {
                        if (res.confirm) {
                            console.log('用户点击确定');
                            API.bankHold({ "buildingId": this.data.id,
                                "money": parseInt(this.num)*100,
                                "token": uni.getStorageSync('token')}).then(res=>{
                                if(res.status==200){
                                    if(res.data.returnCode==0){
                                        uni.showToast()
                                    }else{
                                        uni.showModal({
                                            title: '提示',
                                            content: res.data.returnMsg,
                                            showCancel: false,
                                        });
                                    }
                                }else{
                                    uni.showModal({
                                        title: '提示',
                                        content: '请求失败',
                                        showCancel: false,
                                    });
                                }
                            })
                        } else if (res.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });
            }
        }
    }
</script>
<style scoped>
    .content {
        height: 100%;
        /*padding-top: 20upx;*/
        background: #F3F3F3;
    }
    .company{
        color: rgba(15, 15, 15, 1);
        font-size: 24upx;
        padding-left: 3%;
        font-family: PingFangSC-regular;
    }
    .time-msg{
        color: white;
        background: #D14F43;
        font-size: 24upx;
        padding:1% 3%;
    }
    .user-msg{
        display: flex;
        padding:2% 3%;
        justify-content: space-between;
        background: white;
        flex-wrap: wrap;
        font-size: 24upx;
        color: #090909;
        margin-bottom: 40upx;
        border-bottom: 1px solid rgba(227, 227, 227, 1);
    }
    .plase-select{
        font-size: 30upx;
        padding:2% 3%;
        color: #D14F43;
    }
    .select-item{
        font-size: 24upx;
        padding:0 0 20upx 3%;
    }
    button{
        width: 49%;
        margin-top:30upx;
        background: #D14F43;
        border-radius: 4upx;
        padding-left: 3%;
    }
    .but-wrap{
        display: flex;;
        flex-wrap: wrap;
        justify-content: space-around;
    }
    .input-wrap{
        display: flex;
        justify-content: space-between;
        padding: 0 3%;
        border-bottom: 1px solid rgba(227, 227, 227, 1);
    }
    .input-key{
        font-size: 32upx;
        color: #64727f;
        line-height: 112upx;
    }
    input{
        padding:30upx 0;
        color: #5e93c6;
        font-size: 28upx;
        text-align: right;
        font-family: PingFangSC-regular;
        display: inline-block;
    }
    .sub-button{
        width: 48%;
        margin:30upx 0;
        background: #D14F43;
        border-radius: 4upx;
    }
    .msg{
        font-size:32upx;
        color: #7f5734;
        padding: 20upx;
        margin-top: 40upx;
        border-top: 2px solid rgba(227, 227, 227, 1);
        border-bottom: 2px solid rgba(227, 227, 227, 1);
        background: -webkit-linear-gradient(#e5d7cb, white); /* Safari 5.1 - 6.0 */
        background: -o-linear-gradient(#e5d7cb, white); /* Opera 11.1 - 12.0 */
        background: -moz-linear-gradient(#e5d7cb, white); /* Firefox 3.6 - 15 */
        background: linear-gradient(#e5d7cb, white); /* 标准的语法 */
    }
	.bottom-msg{
		width: 90%;
		margin:20upx 0 0 5%;
		color: rgba(79, 79, 79, 1);
		font-size: 24upx;
		font-family: PingFangSC-regular;
	}

</style>
